package com.jzoom.zoom.admin.models;

import com.jzoom.zoom.common.annotations.Inject;
import com.jzoom.zoom.dao.Page;
import com.jzoom.zoom.dao.Record;
import com.jzoom.zoom.plugin.services.PluginService;

import java.util.Map;

public class PluginDao extends AdminDaoModel {

	public PluginDao() {
		super("sys", "sys_plugin", "id");
	}
	
	@Inject
	private PluginService pluginService;
	
	@Override
	public Page<Record> getPage(Map<String, Object> search) {
		
		Page<Record> page =  super.getPage(search);
		for (Record record : page.getList()) {
			boolean running = pluginService.isRunning(record.getString("id"));
			record.put("running", running);
		}
		
		return page;
		
	}

}
